
<br />
<p class='text-center lead'>新增客户信息</p>

<form class="form-horizontal" role="form" action = "create" method = "post">
	<div class="form-group">
	    <label for="name" class="col-md-2 control-label">客户名*：</label>
		<div class="col-md-4">
			<input type = "text"  class="form-control success" name = "name" id = "client_name" />
		</div>
		<label for="country" class="col-md-2 control-label">国家*：</label>
		<div class="col-md-4">
			<input type = "text"  class="form-control" name = "country" />
		</div>
	</div>
	<div class="form-group">
		<label for="website" class="col-md-2 control-label">网址：</label>
		<div class="col-md-4">
			<input type = "text"  class="form-control" name = "website" />
		</div>
		<label for="type" class="col-md-2 control-label">客户类别*：</label>
		<div class="col-md-4">
			<input type = "text"  class="form-control" name = "type" placeholder = "Owenr, EPC, Service, etc." />
		</div>
	
	</div>
	<div class="form-group">
		<label for="sector" class="col-md-2 control-label">行业：</label>
		<div class="col-md-4">
			<input type = "text"  class="form-control" name = "sector" placeholder = "海上油气, 水处理, 农药化肥, etc." />
		</div>
		<label for="contact_by" class="col-md-2 control-label">负责联系：</label>
		<div class="col-md-4">
		<select class="form-control" name='contact_by'>
			<option value='张晓'>张晓</option>
			<option value='孙静怡'>孙静怡</option>
			<option value='余文卓'>余文卓</option>
		</select>
		</div>
	</div>
	<div class="form-group">
		<label for="scope" class="col-md-2 control-label">业务范围：</label>
		<div class="col-md-10">
			<textarea class='form-control' rows='5' name='scope'></textarea>
		</div>
	</div>
	<div class="form-group">
		<label for="address" class="col-md-2 control-label">地址：</label>
		<div class="col-md-10">
			<input type = "text"  class="form-control" name = "address" />
		</div>
	</div>
	<div class="form-group">
		<label for="remark" class="col-md-2 control-label">备注：</label>
		<div class="col-md-10">
			<input type = "text"  class="form-control" name = "remark" />
		</div>
	</div>
	<br />
	<div class="form-group">
		<div class="col-md-offset-2 col-md-3">
			<input class="btn btn-default" type = "submit" value="添加"/>
		</div>
	</div>
</form>

<table class = "hidden" >
	<thead>
	<tr>
	<th><strong>客户名</strong></th>
	</tr>
	</thead>
	
	<tbody>
	{clients}
		<tr>
		<td>{name}</td>
		</tr>
	{/clients}
	</tbody>
</table>

<script type = "text/javascript" >
	//失去焦点后匹配表格中的内容
		jQuery("#client_name").blur(function (){
			//测试返回的第一个td的值
			last = jQuery("td:last()").text();
			now = jQuery("td:eq(0)").text();
			userin = jQuery(this).val();
			
			warn = "ok";
			i = 0;
			
			while (now != last) {
				//比较now与用户输入，如果一样则修改warn
				if (now == userin) {
					warn = now + "已存在！";
				}
				i++;
				s = "td:eq(" + i + ")"; 
				now = jQuery(s).text();
			}
			
			if (userin == "") {
				warn = "输入不能为空";
			}
			if (warn != "ok") {
			alert(warn);
			}
		});

</script>